package com.syqc.monitor

import com.syqc.comlib.utils.CacheMMKV


object ParamsUtil {
    /**
     * 获取安全报警参数
     *
     * @return
     */
    fun getAdasParams(): List<String>? {
        val adasParams = CacheMMKV.decodeString("ParamsAdasTime")
        if (adasParams.isEmpty()) return null
        val plus = adasParams.split("#")
        return plus.toList()
    }

    /**
     * 保存安全报警参数
     *
     * @param stime
     * @param etime
     * @param typeIds
     * @param speed
     * @param duration
     */
    fun saveAdasParams(
        typeIds: String, speed: String, duration: String
    ) {
        val adas = "$typeIds#$speed#$duration"
        CacheMMKV.encode("ParamsAdasTime", adas)
    }

    /**
     * 获取报警参数
     *
     * @return
     */
    fun getNormalParams(): List<String>? {
        val adasParams = CacheMMKV.decodeString("ParamsNormalTime")
        if (adasParams.isEmpty()) return null
        val plus = adasParams.split("#")
        return plus.toList()
    }

    /**
     * 保存报警参数
     * @param stime
     * @param etime
     * @param typeIds
     * @param speed
     * @param duration
     */
    fun saveNormalParams(
        typeIds: String, speed: String, duration: String
    ) {
        val adas = "$typeIds#$speed#$duration"
        CacheMMKV.encode("ParamsNormalTime", adas)
    }

    /**
     * 获取停车数据
     *
     * @return
     */
    fun getStopCarParams(): List<String>? {
        val adasParams = CacheMMKV.decodeString("ParamsStopCarTime")
        if (adasParams.isEmpty()) return null
        val plus = adasParams.split("#")
        return plus.toList()
    }

    /**
     * 保存停车数据
     * @param stime
     * @param etime
     * @param typeIds
     * @param speed
     * @param duration
     */
    fun saveStopCarParams(
        switchAcc: Boolean, duration: String
    ) {
        val adas = "$switchAcc#$duration"
        CacheMMKV.encode("ParamsStopCarTime", adas)
    }

    /**
     * Save line params  保存历史轨迹查询参数
     *
     * @param speed
     * @param duration
     */
    fun saveLineParams(
        speed: String, duration: String
    ) {
        val line = "$speed#$duration"
        CacheMMKV.encode("ParamsLines", line)
    }

    /**
     * Get line params  获取历史轨迹查询参数
     *
     * @return
     */
    fun getLineParams():List<String>?{
        val lineParams = CacheMMKV.decodeString("ParamsLines")
        if (lineParams.isEmpty()) return null
        val plus = lineParams.split("#")
        return plus.toList()
    }
}